﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="coupons_edit.aspx.cs" Inherits="Donal.Xms.Web.qianyi.common.coupons_edit" ValidateRequest="false" %>

<%@ Import Namespace="Donal.Xms.Common" %>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>编辑优惠卷</title>
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <link rel="stylesheet" type="text/css" href="../../scripts/artdialog/ui-dialog.css" />
    <link rel="stylesheet" type="text/css" href="../skin/icon/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../skin/default/style.css" />
    <script type="text/javascript" charset="utf-8" src="../../scripts/jquery/jquery-1.11.2.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../scripts/jquery/Validform_v5.3.2_min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../scripts/artdialog/dialog-plus-min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../scripts/datepicker/WdatePicker.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../scripts/webuploader/webuploader.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../js/uploader.js"></script>
    <script type="text/javascript" charset="utf-8" src="../js/common.js"></script>
    <script type="text/javascript" charset="utf-8" src="../js/laymain.js"></script>
    <script type="text/javascript">
        $(function () {
            //初始化表单验证
            $("#form1").initValidform();

            //初始化上传控件
            $(".upload-img").InitUploader({ filesize: "<%=sysConfig.imgsize %>", sendurl: "../../tools/upload_ajax.ashx", swf: "../../scripts/webuploader/uploader.swf", filetypes: "<%=sysConfig.fileextension %>" });

            function initialization() {

                switch ($("#hidExpiration_form").val()) {
                    case "0":
                        $("#dlExpiration").hide();
                        $("#dlstart").show();
                        $("#dlend").show();
                        break;
                    case "1":
                        $("#dlExpiration").show();
                        $("#dlstart").hide();
                        $("#dlend").hide();
                        break;
                    case "2":
                        $("#dlExpiration").hide();
                        $("#dlstart").hide();
                        $("#dlend").hide();
                        break;
                }
            };


            $("a").click(function () {
                var htmls = $(this).html();
                if (htmls == "自动过期" || htmls == "分配后在指定天数后过期" || htmls == "永不过期") {
                    switch (htmls) {
                        case "自动过期":
                            setExpiration_hide();
                            $("#dlstart").show();
                            $("#dlend").show();
                            break;
                        case "永不过期":
                            $("#dlExpiration").hide();
                            $("#dlstart").hide();
                            $("#dlend").hide();
                            break;
                        case "分配后在指定天数后过期":
                            $("#dlExpiration").show();
                            $("#dlstart").hide();
                            $("#dlend").hide();
                            break;
                    }
                }

                function setExpiration_hide() {
                    var vs = $("[id$='txtExpiration_num']").val();
                    $("#dlExpiration").hide();
                    $("[id$='txtExpiration_num']").val(vs == "" ? "7" : vs);
                };


                setImagesAndContents();

                function setImagesAndContents() {
                    var imgUrl = "";
                    var txtContents = "";
                    var timer = setInterval(function () {

                        if ($("input[id$='txtImgUrl']").val() != $("#img_page").attr("src")) {
                            imgUrl = $("input[id$='txtImgUrl']").val();
                            $("#img_page").attr("src", imgUrl);
                            $("input[id$='hidImg']").val(imgUrl);
                        }
                    }, 200);
                };

            });

            initialization();

            $("input[name='checkAll']").click(function () {
                if ($(this).prop("checked") == true) {
                    $(this).parent().siblings(".col").find("input[type='radio']").prop("checked", false);
                    $(this).parent().siblings(".col").find("input[type='checkbox']").prop("checked", true);
                } else {
                    $(this).parent().siblings(".col").find("input[type='radio']").prop("checked", false);
                    $(this).parent().siblings(".col").find("input[type='checkbox']").prop("checked", false);
                }
            });

            //创建选择产品类别窗体
            $(".category-btn").click(function () {
                showSelectDialog();
            });

            //初始化选择窗口
            function showSelectDialog(obj) {
                var d = top.dialog({
                    id: 'selectDialogId',
                    width: 800,
                    height: 400,
                    title: "选择适用产品类别",
                    url: 'dialog/dialog_select_category.aspx?action=' + obj,
                    onclose: function () { }
                }).showModal();
                d.data = $("#category_item_box");
            }
        });
        function delTr(obj) {
            $(obj).parent().parent().remove();
        };
    </script>

</head>

<body class="mainbody">
    <form id="form1" runat="server">
        <!--导航栏-->
        <div class="location">
            <a href="coupons_list.aspx" class="back"><i class="iconfont icon-up"></i><span>返回列表页</span></a>
            <a href="../center.aspx"><i class="iconfont icon-home"></i><span>首页</span></a>
            <i class="arrow iconfont icon-arrow-right"></i>
            <span>优惠卷管理</span>
            <i class="arrow iconfont icon-arrow-right"></i>
            <span>编辑优惠券</span>
        </div>
        <div class="line10"></div>
        <!--/导航栏-->

        <!--优惠卷-->
        <div id="floatHead" class="content-tab-wrap">
            <div class="content-tab">
                <div class="content-tab-ul-wrap">
                    <ul>
                        <li><a class="selected" href="javascript:;">编辑优惠券</a></li>
                    </ul>
                </div>
            </div>
        </div>

        <div class="tab-content">
            <dl>
                <dt>名称</dt>
                <dd>
                    <asp:TextBox ID="txtTitle" runat="server" CssClass="input normal" Width="200" datatype="*2-50" sucmsg=" " />
                    <span class="Validform_checktip">*名称最多50个字符</span>
                </dd>
            </dl>
            <dl>
                <dt>启用</dt>
                <dd>
                    <div class="rule-single-checkbox">
                        <asp:CheckBox ID="cbStatus" runat="server" Checked="false" />
                    </div>
                    <span class="Validform_checktip">*启用后才可以使用</span>
                </dd>
            </dl>
            <dl>
                <dt>门槛</dt>
                <dd>
                    <asp:TextBox ID="txtConditions_amount" runat="server" CssClass="input small" datatype="/^(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/" sucmsg=" ">0</asp:TextBox>
                    元                    
                    <span class="Validform_checktip">*当订单金额大于等于设定金额时此券可用。如设置0元，就是无限制。 </span>
                </dd>
            </dl>
            <dl id="dlAmount">
                <dt>优惠金额</dt>
                <dd>
                    <asp:TextBox ID="txtAmount" runat="server" CssClass="input small" datatype="/^(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/" sucmsg=" ">0</asp:TextBox>
                    元                    
                    <span class="Validform_checktip">*金额：此优惠券可用金额。</span>
                </dd>
            </dl>
            <dl>
                <dt>适用产品类别</dt>
                <dd>
                    <a class="icon-btn add category-btn"><span>设置产品类别</span></a>
                    <div class="table-container" style="padding-top: 10px;">
                        <table border="0" cellspacing="0" cellpadding="0" class="border-table" width="82%">
                            <thead>
                                <tr>
                                    <th width="30%">产品类别</th>
                                    <th width="10%">删除</th>
                                </tr>
                            </thead>
                            <tbody id="category_item_box">
                                <asp:Repeater ID="rptCategoryList" runat="server">
                                    <ItemTemplate>
                                        <tr>
                                            <td align="center">
                                                <input type="hidden" name="hidItemId" value="<%# Eval("category_id") %>" />
                                                <%# new Donal.Xms.BLL.products_category().GetTitle(Utils.ObjToInt(Eval("category_id").ToString())) %></td>
                                            <td align="center">
                                                <a style="color: blue; cursor: pointer;" onclick="delTr(this);">删除</a>
                                            </td>
                                        </tr>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </tbody>
                        </table>
                    </div>
                </dd>
            </dl>
            <dl>
                <dt>描述</dt>
                <dd>
                    <asp:TextBox ID="txtContents" runat="server" CssClass="input normal" Width="300" Height="100" TextMode="MultiLine" datatype="*5-500" sucmsg=" " />
                    <span class="Validform_checktip">*描述最多500个字符</span>
                </dd>
            </dl>

            <dl>
                <dt>失效形式</dt>
                <dd>
                    <input type="hidden" id="hidExpiration_form" value="<%=hidExpiration_form %>" />
                    <div class="rule-multi-radio">
                        <asp:RadioButtonList ID="cblExpiration_form" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
                            <asp:ListItem Value="0" Selected="True">自动过期</asp:ListItem>
                            <asp:ListItem Value="1">分配后在指定天数后过期</asp:ListItem>
                            <asp:ListItem Value="2">永不过期</asp:ListItem>
                        </asp:RadioButtonList>
                    </div>
                </dd>
            </dl>

            <dl id="dlExpiration" style="display: none">
                <dt>指定过期天数</dt>
                <dd>
                    <asp:TextBox ID="txtExpiration_num" runat="server" CssClass="input small" Width="200" datatype="n" sucmsg=" " Text="7" />
                    <span class="Validform_checktip">*分配后在指定天数后过期</span>
                </dd>
            </dl>

            <dl id="dlstart">
                <dt>开始日期</dt>
                <dd>
                    <asp:TextBox ID="txtStart_time" runat="server" CssClass="input rule-date-input" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" datatype="/^\s*$|^\d{4}\-\d{1,2}\-\d{1,2}\s{1}(\d{1,2}:){2}\d{1,2}$/" errormsg="请选择正确的日期" sucmsg=" " />
                    <asp:Label ID="div_Start_time_tip" runat="server" CssClass="Validform_checktip" />
                </dd>
            </dl>
            <dl id="dlend">
                <dt>结束日期</dt>
                <dd>
                    <asp:TextBox ID="txtEnd_time" runat="server" CssClass="input rule-date-input" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" datatype="/^\s*$|^\d{4}\-\d{1,2}\-\d{1,2}\s{1}(\d{1,2}:){2}\d{1,2}$/" errormsg="请选择正确的日期" sucmsg=" " />
                    <span class="Validform_checktip">*结束日期：在自动过期形式下起作用。</span>
                </dd>
            </dl>
            <dl>
                <dt>排序</dt>
                <dd>
                    <asp:TextBox ID="txtSort_id" runat="server" CssClass="input small" Width="200" datatype="n" sucmsg=" " Text="99" />
                    <asp:Label ID="div_Sort_id_tip" runat="server" CssClass="Validform_checktip" />
                </dd>
            </dl>         
        </div>

        <!--/优惠卷-->

        <!--工具栏-->
        <div class="page-footer">
            <div class="btn-wrap">
                <asp:Button ID="btnSubmit" runat="server" Text="提交保存" CssClass="btn" OnClick="btnSubmit_Click" />
                <input name="btnReturn" type="button" value="返回上一页" class="btn yellow" onclick="javascript: history.back(-1);" />
            </div>
        </div>
        <!--/工具栏-->

    </form>
</body>
</html>

